package com.chencs.app.lianmeng.controller;


import com.alibaba.fastjson.JSON;
import com.chencs.app.lianmeng.mapper.LMProductMapper;
import com.chencs.app.lianmeng.service.LMProductSer;
import com.chencs.vo.biz.lianmeng.LmCategory;
import com.chencs.vo.net.lmrequest.LmCategoryItemRequest;
import com.chencs.vo.net.lmrequest.LmCategoryRequest;
import com.chencs.vo.net.lmrequest.LmProductRequest;
import com.chencs.vo.net.lmrequest.LmRegisterRequest;
import com.chencs.vo.net.lmresponse.LmCategoryItemResponse;
import com.chencs.vo.net.lmresponse.LmCategoryResponse;
import com.chencs.vo.net.lmresponse.LmGetCouponsResponse;
import com.chencs.vo.net.lmresponse.LmProductResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 产品相关
 */
@RestController
@RequestMapping("/app/lmProduct")
public class LMProductCtr {


    @Autowired
    private LMProductSer lmProductSer;


    /**
     * 获取商品详情
     * @param request
     * @return
     */
    @RequestMapping(value = "/findProduct", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String findProductByPid(@RequestBody LmProductRequest request){
        LmProductResponse response = lmProductSer.findProductByPid(request);
        return JSON.toJSONString(response);
    }


    /**
     * 获取大分类
     * @param request
     * @return
     */
    @RequestMapping(value = "/getCategory", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String getCategory(@RequestBody LmCategoryRequest request){
        LmCategoryResponse response = lmProductSer.getCategory(request);
        return JSON.toJSONString(response);
    }


    /**
     * 获取小分类
     * @param request
     * @return
     */
    @RequestMapping(value = "/getCategoryItem", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String getCategoryItem(@RequestBody LmCategoryItemRequest request){
        LmCategoryItemResponse response = lmProductSer.getCategoryItem(request);
        return JSON.toJSONString(response);
    }


    /**
     * 领券
     * @param request
     * @return
     */
    @RequestMapping(value = "/getCoupons", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String getCoupons(@RequestBody LmProductRequest request){
        LmGetCouponsResponse response = lmProductSer.getCoupons(request);
        return JSON.toJSONString(response);
    }


}
